package api

import (
	"api-gateway/basic/inits"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"api-gateway/handler/response"
	"github.com/gin-gonic/gin"
)

/*
DeepSeekGetAnswer 对接ai
功能：

    -向ai提问寻求答案

参数：

    c *gin.Context: Gin框架的上下文对象

请求示例：

    POST /v1/healthDoctor/deepSeekGetAnswer
    {
      "user_id": 1,
      "question": 西瓜的英文名,
    }

返回值：

    成功: { "code":200, "msg":"解答成功", "data": 西瓜的英文是 **"watermelon"**（发音：/ˈwɔːtərmelən/） }
    失败: { "code":400/500, "msg":"错误信息", "data": err }

作者：汪腾
*/
//DeepSeekGetAnswer
//@Summary      AI提问
//@Description  向AI提问寻求答案
//@Tags         AI模块
//@Accept       json
//@Produce      json
//@Param        healthDoctor  body      request.DeepSeekGetAnswerReq  true  "AI参数"
//@Success      200  {object}  response.Response
//@Failure      400   {object}  response.Response
//@Router       /healthDoctor/deepSeekGetAnswer [post]
func DeepSeekGetAnswer(c *gin.Context) {
	var req request.DeepSeekGetAnswerReq
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, 400, "参数错误", err.Error())
		return
	}

	res, err := inits.UserCline.DeepSeekGetAnswer(c, &__.DeepSeekGetAnswerReq{
		UserId:   int64(req.UserId),
		Question: req.Question,
		RoomId:   int64(req.RoomId),
	})
	if err != nil {
		response.Error(c, 500, "无法解答", err.Error())
		return
	}
	response.Success(c, "解答成功", res)
}

/*
HistoryQuestion 提问历史
功能：

	-查找ai提问历史 （倒数十条）

参数：

	c *gin.Context: Gin框架的上下文对象

请求示例：

	GET /v1/healthDoctor/historyQuestion
	{
	  "user_id": 1,
	}

返回值：

	   成功: { "code":200, "msg":"查询成功", "data": "list": [
	      {
	         "id": 1,
	         "userId": 1,
	         "problem": "西瓜的英文",
	         "reply": "西瓜的英文是 **\"watermelon\"**（发音：/ˈwɔːtərmelən/）"
	      }
	   ]
	}
	失败: { "code":400/500, "msg":"错误信息", "data": err }

作者：汪腾
*/
//HistoryQuestion
//@Summary      获取提问历史
//@Description  获取提问历史
//@Tags         AI模块
//@Accept       json
//@Produce      json
//@Param        healthDoctor  query      request.QuestionHistory  true  "AI参数"
//@Success      200  {object}  response.Response
//@Failure      400   {object}  response.Response
//@Router       /healthDoctor/historyQuestion [get]
func HistoryQuestion(c *gin.Context) {
	var req request.QuestionHistory
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, 400, "参数错误", err.Error())
		return
	}
	res, err := inits.UserCline.DeepSeekHistory(c, &__.DeepSeekHistoryReq{
		UserId: int64(req.UserId),
		RoomId: int64(req.RoomId),
	})
	if err != nil {
		response.Error(c, 500, "查询失败", err.Error())
		return
	}
	response.Success(c, "查询成功", res)
}
